<%@ include file="/common/taglibs.jsp"%>
<%@ page language="java" pageEncoding="utf8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US" dir="ltr">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<link rel="stylesheet" href="<c:url value="/css/shopadmin.css"/>" type="text/css" />
		<link rel="stylesheet" href="<c:url value='/scripts/themes/base/jquery.ui.all.css'/>" type="text/css" />

	</head>
	<body style="">
		<div id="headBar" class="head_content">
			<div class="finder-action" id="">
				<div class="finder-action-inner clearfix">
					<a type="link" href="#" onclick="window.open('gd_goods_add.html', 'newwin',	'status=no,toolbar=no,menubar=no,location=no')" class="btn btn-blank"><span><span><i
								class="finder-icon"><img src="<c:url value="/images/transparent.gif"/>" class="imgbundle icon" style="width: 24px; height: 24px; background-position: 0pt -316px;" /> </i>添加商品</span> </span> </a>
					<button type="button"  onclick='opednBatchUpdateDialog()' class="btn btn-x-large">
						<span><span><i class="finder-icon"><img src="<c:url value="/images/transparent.gif"/>" class="imgbundle icon"
										style="width: 22px; height: 24px; background-position: 0pt -548px;" /> </i>批量操作<img src="<c:url value="/images/transparent.gif"/>" class="drop-handle" /> </span> </span>
					</button>
					<button type="button" onclick="location.reload();" class="btn">
						<span><span><i class="finder-icon"><img src="<c:url value="/images/transparent.gif"/>" class="imgbundle icon"
										style="width: 22px; height: 24px; background-position: 0pt -644px;" /> </i>刷新</span> </span>
					</button>
					<button type="button" onclick="batchGoodsDelete()" class="btn">
						<span><span><i class="finder-icon"><img src="<c:url value="/images/transparent.gif"/>" class="imgbundle icon"
										style="width: 17px; height: 24px; background-position: 0pt -757px;" /> </i>删除</span> </span>
					</button>

 
					<button type="button" class="btn" onclick="batchMarketSubmit(true)">
						<span><span><i class="finder-icon"><img src="<c:url value="/images/transparent.gif"/>" class="imgbundle icon"
										style="width: 25px; height: 24px; background-position: 0pt -484px;" /> </i>批量上架</span> </span>
					</button>
					<button type="button" class="btn" onclick="batchMarketSubmit(false)">
						<span><span><i class="finder-icon"><img src="<c:url value="/images/transparent.gif"/>" class="imgbundle icon"
										style="width: 25px; height: 24px; background-position: 0pt -484px;" /> </i>批量下架</span> </span>
					</button>
					<button type="button" class="btn" onclick="openGoodsSearchDialog()">
						<span><span><i class="finder-icon"><img src="<c:url value="/images/transparent.gif"/>" class="imgbundle icon"
										style="width: 26px; height: 24px; background-position: 0pt -460px;" /> </i>搜索</span> </span>
					</button>
				</div>
			</div>

			<div id="" class="finder-header">

				<table cellpadding="0" cellspacing="0" width="100%">
					<!----cols---->
					<col style="width: 24px;" class="span-select" />
					<col style="width: 48px;" />
 					<col style="width: 110px;" />
					<col style="width: 310px;" />
					<col style="width: 75px;" />
					<col style="width: 75px;" />
					<col style="width: 50px;" />
					<col style="width: 50px;" />
					<col style="width: 75px;" />
					<col style="width: 75px;" />
					<col style="width: 30px;" />
					<col style="width: 75px;" />
					<col style="width: 75px;" />
					<col />
					<!----cols---->
					<thead>
						<tr>
							<td>
								<input class="sellist" name="" id="check_goods_ids" type="checkbox" />
							</td>
							<td>
								&nbsp;查看
							</td> 
							
							<td>
								<div class="cell orderable">
									<table cellpadding="0" cellspacing="0" width="100%">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label"> 名称</span>
												</td>

											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								<div class="cell orderable">
									<table cellpadding="0" cellspacing="0" width="100%">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">引擎</span>
												</td>

											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								<div class="cell orderable" key="cat_id">
									<table cellpadding="0" cellspacing="0" width="100%">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">变速箱</span>
												</td>

											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								<div class="cell orderable" key="price">
									<table cellpadding="0" cellspacing="0" width="100%">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label"> </span>
												</td>

											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								<div class="cell orderable" key="store">
									<table cellpadding="0" cellspacing="0" width="100%">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">库存</span>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								<div class="cell orderable" key="marketable">
									<table cellpadding="0" cellspacing="0" width="100%">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">上架</span>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								<div class="cell orderable" key="brand_id">
									<table cellpadding="0" cellspacing="0" width="100%">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">品牌</span>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								<div class="cell orderable" key="weight">
									<table cellpadding="0" cellspacing="0" width="100%">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">销售价</span>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								<div class=" ">
									<table cellpadding="0" cellspacing="0" width="100%">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label"> </span>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								<div class="cell orderable" key="type_id">
									<table cellpadding="0" cellspacing="0" width="100%">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">周末价</span>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								<div class="cell orderable" key="mktprice">
									<table cellpadding="0" cellspacing="0" width="100%">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">节日价</span>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								<div class="cell orderable" key="mktprice">
									<table cellpadding="0" cellspacing="0" width="100%">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">&nbsp;</span>
												</td>
											</tr>
										</tbody>
									</table>
								</div>

							</td>
						</tr>
					</thead>
				</table>

			</div>

		</div>
		<div id="main" class="main_content">
			<form id="goods_batchDelete_form" name="gEditor" method="post" action="gd_goods_batchDelete.html">

				<div class="finder-list finder-list-normal" id="goods_list_rows">
					<table cellpadding="0" cellspacing="0" width="100%" id="tbl_goods">
						<!----cols---->
						<col style="width: 24px;" class="span-select" />
						<col style="width: 48px;" />
 						<col style="width: 110px;" />
						<col style="width: 310px;" />
						<col style="width: 75px;" />
						<col style="width: 75px;" />
						<col style="width: 50px;" />
						<col style="width: 50px;" />
						<col style="width: 75px;" />
						<col style="width: 75px;" />
						<col style="width: 30px;" />
						<col style="width: 75px;" />
						<col style="width: 75px;" />
						<col />
						<!----cols---->
						<tbody>

							<c:forEach var="list" items="${autoes}" varStatus="status1">
								<tr class="row">
									<td>
										<input class="sel" name="autoes[${status1.index}].goodsId" value="${list.autoId}" type="checkbox" />
									</td>
									<td class="finder-list-command">
										<a   href="auto_edit.do?autoId=${list.autoId}"  ><img src="<c:url value="/images/transparent.gif"/>" class="imgbundle" style="width: 16px; height: 16px; background-position: 0pt -1811px;" /> </a>
									</td> 
									
									<td class="editable">
										<div class="cell">
											${list.name}
										</div>
									</td>
									<td class="editable">
										<div class="cell">
											${list.engine}
										</div>
									</td>
									<td class="editable">
										<div class="cell">
											${list.gearbox}
										</div>
									</td>
									<td>
										<div class="cell">
											
										</div>
									</td>
									<td key="store">
										<div class="cell">
											${list.autoCount}
										</div>
									</td>
									<td class="editable">
										<div class="cell">
											<c:if test="${list.marketOn}">上架</c:if>
											<c:if test="${!list.marketOn}">下架</c:if>
										</div>
									</td>
									<td class="editable">
										<div class="cell">
											${list.brandId}
										</div>
									</td>
									<td>
										<div class="cell">
											 ${list.price}
										</div>
									</td>
									<td class="editable">
										<div class="cell">
											 
										</div>
									</td>
									<td>
										<div class="cell">
											${list.holidayPrice}
										</div>
									</td>
									<td>
										<div class="cell">
											${list.weekendPrice}
										</div>
									</td>
									<td>
										&nbsp;
									</td>
								</tr>
							</c:forEach>
						</tbody>
					</table>

					<div id="hidden_update_input" style="display: hidden;"></div>
				</div>
			</form>
		</div>
		<table class="tbl" style="display: hidden;"> </table>
		<div id="footBar" class="foot_content">
			<div style="" class="finder-footer">
				<div class="finder-page clearfix">					
					<div class="pager"></div> 
				</div>
			</div>
		</div>
		<div id="goods_batch_update_dialog" title="批量更新" style="display: none;">
			<form id="goods_batch_update_form" name="gEditor" method="post" action="gd_goods_batchUpdate.html">
				<input type="hidden" name="goodsBatchUpdateParameter.marketOn" id="market_on" value="" />
				<input type="hidden" id="updateGoods_Ids" name="goodsBatchUpdateParameter.updateGoodsIds" />
				<div id="goods_batch_update_tab">
					<div class="division">
						<div class="notice">

							警告：本操作可强制修改所选商品的，请谨慎操作。
							<br />
							直接修改：对所选商品的某个价格/库存进行统一修改。
							<br />
							公式修改：将所选商品的某个价格/库存修改为在另一个价格的基础上加减乘一个数字。
							<br />
						</div>

						<table cellspacing="0" cellpadding="0" border="0">
							<tbody>
								<tr>
									<th style="width: 20px;">
										&nbsp;&nbsp;&nbsp;&nbsp;
									</th>
									<th>
										<label for="bated_ipt_uniformStore">
											修改品牌
										</label>

									</th>
									<td>
										<select name="goodsBatchUpdateParameter.brandId" id="batch_update_brandId" class="x-input-select  inputstyle">
											<option value="">
												--请选择--
											</option>
											<option value="0">
												系统默认品牌
											</option>
											 
										</select>
									</td>
								</tr>

							</tbody>
						</table>
						<table cellspacing="0" cellpadding="0" border="0">
							<tbody>
								<tr>
									<th style="width: 20px;">
										<input type="radio" id="ipt_enable_uniformStore" checked='checked' value="store" name="goodsBatchUpdateParameter.updateStoreType">
									</th>
									<th>
										<label for="bated_ipt_uniformStore">
											修改 库存
										</label>
									</th>
									<td>
										<input type="text" name="goodsBatchUpdateParameter.store" id="bated_ipt_uniformStore" onfocus="$('#ipt_enable_uniformStore').attr('checked','true')" class="x-input ">
									</td>
								</tr>
								<tr>
									<th style="width: 20px;">
										<input type="radio" id="ipt_enable_uniformStoreByOperator" value="storeByOperator" name="goodsBatchUpdateParameter.updateStoreType">
									</th>
									<th>
										<label for="bated_ipt_uniformStoreByOperator">
											公式调库存：
										</label>
									</th>
									<td>
										调整后库存&nbsp;=&nbsp;当前库存&nbsp;&nbsp;
										<select id="updateOperator" name="goodsBatchUpdateParameter.storeOperator" class="x-input-select  inputstyle">
											<option value="+" selected="selected">
												+
											</option>
											<option value="-">
												-
											</option>
										</select>
										<input type="text" name="goodsBatchUpdateParameter.storeByOperator" style="width: 80px;" id="bated_ipt_uniformStoreByOperator"
											onfocus="$('#ipt_enable_uniformStoreByOperator').attr('checked','true')" class="x-input " autocomplete="off">
									</td>
								</tr>
							</tbody>
						</table>


						<table cellspacing="0" cellpadding="0" border="0">
							<tbody>
								<tr>
									<th style="width: 20px;">
										<input type="radio" id="ipt_enable_uniformPrice" checked='checked' value="price" name="goodsBatchUpdateParameter.updatePriceType" />
									</th>
									<th>
										<label for="bated_ipt_uniformPrice">
											修改价格
										</label>
									</th>
									<td>
										<select id="ipt_enable_uniformPrice_updatename" name="goodsBatchUpdateParameter.priceType" class="x-input-select  inputstyle">
											<option value="mktPrice">
												市场价
											</option>
											<option value="price" selected="selected">
												销售价
											</option>
											<option value="cost">
												成本价
											</option>

										</select>
										=
										<input type="text" name="goodsBatchUpdateParameter.price" id="bated_ipt_uniformPrice" onfocus=";$('#ipt_enable_uniformPrice').attr('checked','true')" class="x-input " autocomplete="off">
									</td>
								</tr>
								<tr>
									<th style="width: 20px;">
										<input type="radio" id="ipt_enable_uniformPriceByOperator" value="priceByOperator" name="goodsBatchUpdateParameter.updatePriceType">
									</th>
									<th>
										<label for="bated_ipt_uniformPriceByOperator">
											公式调价格
										</label>
									</th>
									<td>
										<select id="updatePriceName" name="goodsBatchUpdateParameter.destPriceType" class="x-input-select  inputstyle">
											<option value="mktPrice">
												市场价
											</option>
											<option value="price" selected="selected">
												销售价
											</option>
											<option value="cost">
												成本价
											</option>
										</select>
										=
										<select id="updateFromName" name="goodsBatchUpdateParameter.srcPriceType" class="x-input-select  inputstyle">
											<option value="mktPrice">
												市场价
											</option>
											<option value="price">
												销售价
											</option>
											<option value="cost" selected="selected">
												成本价
											</option>
										</select>
										<select id="updateOperator" name=" goodsBatchUpdateParameter.priceOperator" class="x-input-select  inputstyle">
											<option value="+" selected="selected">
												+
											</option>
											<option value="*">
												x
											</option>
										</select>
										<input type="text" name="goodsBatchUpdateParameter.priceByOperator" id="bated_ipt_uniformPriceByOperator" onfocus=";$('#ipt_enable_uniformPriceByOperator').attr('checked','true')"
											class="x-input " autocomplete="off">
									</td>
								</tr>
							</tbody>
						</table>

					</div>

					<div class="mainFoot">
						<table cellspacing="0" cellpadding="0" border="0" align="center" class="table-action">
							<tbody>
								<tr>
									<td>
										<button class="sysiconBtnNoIcon" onclick="batchEditSubmit()">
											保存
										</button>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div>
			</form>
		</div>


		<div id="goods_search_dialog" title="商品搜索" style="display: none;">
			<div id="search-tab">
				<form id="goods_search_form" name="gEditor" method="post" action="gd_goods_list.html">
					<input type="hidden" id="page_id" name="pagerId" />

					<div id="selector-panel-form">
						<div id=" ">
							<div class="gridlist">
								<div class="row">
									<div class="row-line">
										<div class="span-3">
											品牌
										</div>
										<div class="span-3">
											是&nbsp;
										</div>
										<div class="span-6">
											<div class="object-select clearfix">
												<select name="goodsSelectParameter.brandId" id="search_brandId" class="x-input-select  inputstyle">
													<option value="">
														请选择
													</option>
													<c:forEach var="list" items="${goodsBrands}" varStatus="status1">
														<option value="${list.brandId }">
															${list.brandName }
														</option>
													</c:forEach>
												</select>

											</div>
										</div>
										<div class="span-1">

										</div>
									</div>
								</div>
								<div class="row">
									<div class="row-line">
										<div class="span-3">
											销售价
										</div>
										<div class="span-3">
											<select class="x-input-select  inputstyle" id="search_price_selector" name="goodsSelectParameter.priceSelector">
												<option value="than">
													大于
												</option>
												<option value="lthan">
													小于
												</option>
												<option value="equal">
													等于
												</option>
												<option value="sthan">
													小于等于
												</option>
												<option value="bthan">
													大于等于
												</option>
											</select>
											&nbsp;
										</div>
										<div class="span-6">
											<input class="x-input" name="goodsSelectParameter.price" id="search_price" value="" type="text" />
										</div>
										<div class="span-1">

										</div>
									</div>
								</div>
								<div class="row">
									<div class="row-line">
										<div class="span-3">
											货号
										</div>
										<div class="span-3">
											&nbsp;
										</div>
										<div class="span-6">
											<input class="x-input " name="goodsSelectParameter.bn" type="text" id="search_bn" />
										</div>
										<div class="span-1">

										</div>
									</div>
								</div>
								<div class="row">
									<div class="row-line">
										<div class="span-3">
											商品名称
										</div>
										<div class="span-3">

											&nbsp;
										</div>
										<div class="span-6">
											<input class="x-input " name="goodsSelectParameter.name" type="text" id="search_name" />
										</div>
										<div class="span-1">

										</div>
									</div>
								</div>
								<div class="row">
									<div class="row-line">
										<div class="span-3">
											上架
										</div>
										<div class="span-3">
											&nbsp;
										</div>
										<div class="span-6">

											<select class="x-input-select  inputstyle" name="goodsSelectParameter.marketOn" id="search_marketOn">
												<option value="">
													无
												</option>
												<option value="true">
													上架
												</option>
												<option value="false">
													下架
												</option>

											</select>
											&nbsp;
										</div>
										<div class="span-1">

										</div>
									</div>
								</div>
								<div class="row">
									<div class="row-line">
										<div class="span-3">
											库存
										</div>
										<div class="span-3">
											<select class="x-input-select  inputstyle" name="goodsSelectParameter.storeSelector" id="search_store_selector">
												<option value="than">
													大于
												</option>
												<option value="lthan">
													小于
												</option>
												<option value="equal">
													等于
												</option>
												<option value="sthan">
													小于等于
												</option>
												<option value="bthan">
													大于等于
												</option>
											</select>
											&nbsp;
										</div>
										<div class="span-6">
											<input class="x-input " name="goodsSelectParameter.store" type="text" id="search_store" />
										</div>
										<div class="span-1">

										</div>
									</div>
								</div>

							</div>
						</div>
					</div>
					<div class="scrollhandle toLeft gridlist-head" style="text-align: center;">
						<button type="button" class="btn" onclick="searchSubmit(1)">
							<span><span>&nbsp;&nbsp;搜索&nbsp;&nbsp;</span> </span>
						</button>
					</div>
				</form>
			</div>

		</div>



		<script type="text/javascript" src="<c:url value='/scripts/jquery-1.4.2.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/scripts/jquery.bgiframe-2.1.1.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/scripts/ui/jquery.ui.core.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/scripts/ui/jquery.ui.widget.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/scripts/ui/jquery.ui.mouse.js'/> "></script>
		<script type="text/javascript" src="<c:url value='/scripts/ui/jquery.ui.button.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/scripts/ui/jquery.ui.draggable.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/scripts/ui/jquery.ui.position.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/scripts/ui/jquery.ui.dialog.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/scripts/ui/jquery.effects.core.js'/> "></script>
		<%@ include file="/jsp/admin/common/messages.jsp"%>
		<script type="text/javascript" src="<c:url value='/scripts/jquery.pager.js'/>"></script>
		
<script src="<c:url value='/scripts/vm_pagination.js'/>"></script>
<script>
$(function(){
	$('table.tbl').pagination({
		pager : "div.pager" ,
		currentPage : ${autoSearch.pageCurrentPage} ,
		totalPage : ${autoSearch.pageTotalPage} ,
		recordCount : ${autoSearch.pageTotalRow }
	});
	
	 
});

</script>
		<script type="text/javascript">
		
	function batchGoodsDelete(){
		if(!confirm('<fmt:message key="common.confirm_deleted" />')){
			return;	
		}
		var selectedGoodsIds = '';
		$('#tbl_goods input[type=checkbox]').each( function(i, dom){
			if($(dom).attr("checked")){
				selectedGoodsIds+=$(dom).val()+',';
			}							
		});	 
		
		if(selectedGoodsIds==''){
			alert('请选择商品');
			$('#goods_batch_update_dialog').dialog('close');
			return;
		}
		$('#goods_batchDelete_form').submit();
	}
	
	function batchMarketSubmit(flag) {		
		$('#market_on').attr('value',flag);
		batchEditSubmit();
	}
	
	function batchEditSubmit() {
		if(!confirm('确定执行操作吗?')){
			return;	
		}
		
		var selectedGoodsIds = '';
		$('#tbl_goods input[type=checkbox]').each( function(i, dom){
			if($(dom).attr("checked")){
				selectedGoodsIds+=$(dom).val()+',';
			}							
		});
		
		selectedGoodsIds = selectedGoodsIds.substr(0,(selectedGoodsIds.length-1));
		
		if(selectedGoodsIds==''){
			alert('请选择商品');
			$('#goods_batch_update_dialog').dialog('close');
			return;
		}
		 
		$('#updateGoods_Ids').attr('value',selectedGoodsIds);
		 
		$('#goods_batch_update_form').submit();

	}

	$("#check_goods_ids").click(function() {
			if (this.checked) {
				$('input[type=checkbox]').attr("checked", true);
				
				$('#tbl_goods >tbody> tr').addClass('selected');
			} else {
				$('input[type=checkbox]').attr("checked", false);
				$('#tbl_goods > tbody > tr').removeClass('selected');
			}
	});


	function searchSubmit(pageId){
		$('#page_id').attr('value',pageId);
		$('#goods_search_form').submit();
	}

	


	$(function() {

		$("#goods_batch_update_dialog").dialog( {
			autoOpen : false,
			height : 400,
			width : 750,
			modal : true,
			close : function() {
				 
			}
		});
	});
	function opednBatchUpdateDialog() {
		$('#goods_batch_update_dialog').dialog('open');
	}
	
	
		$(function() {	
			
        	$("#goods_search_dialog").dialog({
				autoOpen: false,
				height: 350,
				width: 550,
				modal: true,
				close: function() {
					 
				}
			});
        });
        function openGoodsSearchDialog(){		 	
			$('#goods_search_dialog').dialog('open');
		}
		
		<c:if test="${not empty goodsSelectParameter}" >		   
		   $('#search_brandId').attr('value', '${goodsSelectParameter.brandId}');
			$('#search_price_selector').attr('value','${goodsSelectParameter.priceSelector}');
			$('#search_price').attr('value','${goodsSelectParameter.price }');
			$('#search_bn').val( '${goodsSelectParameter.bn}' );
			$('#search_name').val( '${goodsSelectParameter.name}');
			$('#search_store_selector').attr('value', '${goodsSelectParameter.storeSelector}');
			$('#search_store').val( '${goodsSelectParameter.store}' );
			$('#search_marketOn').attr('value', '${goodsSelectParameter.marketOn}');				
		</c:if>
		
		
		
</script>


	</body>
</html>